package com.googlecode.gwt.wii.wiimote;

import com.google.gwt.core.client.JavaScriptObject;


public class Wiimote {

	private final static Wiimote WIIMOTE0 = new Wiimote(wiimote(0));
	private final static Wiimote WIIMOTE1 = new Wiimote(wiimote(1));
	private final static Wiimote WIIMOTE2 = new Wiimote(wiimote(2));
	private final static Wiimote WIIMOTE3 = new Wiimote(wiimote(3));
	
	private final static Wiimote WIIMOTE[] = {WIIMOTE0, WIIMOTE1, WIIMOTE2, WIIMOTE3};
	
	private final JavaScriptObject wiimote;
	
	private Wiimote(final JavaScriptObject wiimote) {
		super();
		
		this.wiimote = wiimote;
	}

	public static Wiimote getWiimote(int wiimotenumber){
		Wiimote retVal = new Wiimote(wiimote(wiimotenumber));
		
		return retVal;
	}
	
	private static native JavaScriptObject wiimote(int wiimotenumber) /*-{
	  return $wnd.opera.wiiremote.update(wiimotenumber);
	}-*/;

	private native float getProperty(String property) /*-{
	  return this.@com.googlecode.gwt.wii.wiimote.Wiimote::wiimote[property];
	}-*/;	

	public float isEnabled() {
		return getProperty("isEnabled");
	}
		
	public float isDataValid() {
		return getProperty("isDataValid");
	}

	public float isBrowsing() {
		return getProperty("isBrowsing");
	}

	public float dpdScreenX() {
		return getProperty("dpdScreenX");
	}

	public float dpdScreenY() {
		return getProperty("dpdScreenY");
	}

	public float dpdX() {
		return getProperty("dpdX");
	}

	public float dpdY() {
		return getProperty("dpdY");
	}

	public float hold() {
		return getProperty("hold");
	}

	public float dpdRollX() {
		return getProperty("dpdRollX");
	}

	public float dpdRollY() {
		return getProperty("dpdRollY");
	}

	public float dpdDistance() {
		return getProperty("dpdDistance");
	}

	public float dpdValidity() {
		return getProperty("dpdValidity");
	}

}
